<template>
	<view>
		<mumu-one-code @success='handlerSuccess' definition :readers='["ean_reader"]'></mumu-one-code>
	</view>
</template>

<script>
	import MumuOneCode from '@/uni_modules/mumu-oneCode/components/mumu-oneCode/mumu-oneCode.vue'
	export default {
		components: {
			MumuOneCode
		},
		data() {
			return {
				readers:["code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader","2of5_reader","code_93_reade"],
				shop_id:','//店鋪id
			}
		},
		onLoad(options) {
			this.shop_id = options.id
		},
		methods: {
			handlerSuccess(code) {
				this.http.request('/api/shop/listGoods', 'POST', {
					page:1,
					limit:100,
					shop_id: this.shop_id,
					shopclassify_id: "",
					type: 0,
					name: "",
					barcode:code
				}).then(res=>{
					if(res.code==1 && res.data.data.length){
						uni.redirectTo({
							url: "/pages_index/goodsInfo?id=" + res.data.data[0].id
						})
					}else{
						uni.navigateBack(1)
					}
				})
				
			}
			
		}
	}
</script>

<style>

</style>